﻿using System;
using System.Windows;
using System.Windows.Controls;
using VNet.VisiSuite.Common.Logger;

namespace VNet.VisiSuite.Controls
{
    public partial class MetroIconButton
    {
        public MetroIconButton()
        {
            //DataContext = null;
            InitializeComponent();
        }

        private void OnButtonSelection(object sender, RoutedEventArgs e)
        {
            try
            {
                //hidePanel();
                var button = (Button)sender;
                ((VNetMenuItem)button.DataContext).Selected();
            }
            catch (Exception ex)
            {
                FileLog.Error("OnButtonSelection() - ", ex);
            }
        }
    }

    public class MyContentTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var value = item as string;
            DataTemplate res = null;

            if (value != null)
                res = (DataTemplate)VNetUserControl.FindResource(value);

            return res;
        }
    }
}